/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package batis;

import java.io.Reader;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

/**
 *
 * @author Miguel Y Juanan - Telecor
 */
public class MyBatisSqlSessionFactory {
    protected static final SqlSessionFactory FACTORY;

    static {
        try {
            Reader reader = Resources.getResourceAsReader( "batis/mybatis.config.xml" );
            FACTORY = new SqlSessionFactoryBuilder().build(reader);
        } catch (Exception e){
            System.out.println(e);
            throw new RuntimeException( "Fatal Error.  Cause: " + e, e);
        }
    }

    public static SqlSessionFactory getSqlSessionFactory() {
        return FACTORY;
    }
}
